package dk.dtu.is.model.iec61850.ln;

import java.io.Serializable;

import dk.dtu.is.utility.jess.BeanSupport;

/**
 * This class maps the logical node ZCEV. ZCEV has been suggested as an
 * extension of the IEC 61850 standard by CEE-DTU At the moment, for
 * demonstration purposes, only three attributes have been implemented.
 * 
 * @author dsac
 * 
 */
public class Zcev extends BeanSupport implements Serializable {

	/**
	 * Default value for the serialization.
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * The State of Charge of the battery (dimension-less, between 0 and 1)
	 */
	private float soc;

	/**
	 * The Voltage of the battery pack (V)
	 */
	private float vol;

	/**
	 * The Voltages of the cells of the battery pack (V)
	 */
	private float[] cellVols;

	/**
	 * The drain Current of the battery (A) Of course, this is not equal to 0
	 * only when charging or discharging
	 */
	private float cur;

	/**
	 * Default constructor
	 */
	public Zcev() {

	}

	/**
	 * @return The State of Charge of the battery (dimension-less, between 0 and
	 *         1)
	 */
	public float getSoc() {
		return soc;
	}

	/**
	 * @param soc
	 *            The State of Charge of the battery (dimension-less, between 0
	 *            and 1)
	 */
	public void setSoc(float soc) {
		float oldValue = this.soc;
		float newValue = soc;
		pcs.firePropertyChange("soc", oldValue, newValue);
		this.soc = newValue;
	}

	/**
	 * @return The Voltage of the battery pack (V)
	 */
	public float getVol() {
		return vol;
	}

	/**
	 * @param vol
	 *            The Voltage of the battery pack (V)
	 */
	public void setVol(float vol) {
		float oldValue = this.vol;
		float newValue = vol;
		pcs.firePropertyChange("vol", oldValue, newValue);
		this.vol = newValue;
	}

	/**
	 * @return The drain Current of the battery (A) Of course, this is not equal
	 *         to 0 only when charging or discharging
	 */
	public float getCur() {
		return cur;
	}

	/**
	 * @param cur
	 *            The drain Current of the battery (A) Of course, this is not
	 *            equal to 0 only when charging or discharging
	 */
	public void setCur(float cur) {
		float oldValue = this.cur;
		float newValue = cur;
		pcs.firePropertyChange("cur", oldValue, newValue);
		this.cur = newValue;
	}

	/**
	 * Gets the cell voltages of the battery.
	 * 
	 * @return the cell voltage of the battery
	 */
	public float[] getCellVols() {
		return cellVols;
	}

	/**
	 * Sets the cell voltages of the battery.
	 * 
	 * @param cellVols
	 *            the new cell volts
	 */
	public void setCellVols(float[] cellVols) {
		float[] oldValue = this.cellVols;
		float[] newValue = cellVols;
		pcs.firePropertyChange("cellVols", oldValue, newValue);
		this.cellVols = newValue;
	}

	@Override
	// TODO: possibly add the list of cell voltages or only the minimum and
	// maximum or something about them
	public String toString() {
		String zcevString = "ZCEV [";
		zcevString += "SOC=";
		zcevString += this.soc + ", ";
		zcevString += "Vol=";
		zcevString += this.vol + ", ";
		zcevString += "Cur=";
		zcevString += this.cur;
		zcevString += "]";

		return zcevString;
	}

}
